const express = require('express');
const router = express.Router();

router.get('/forCurrentUser', (req, res) => {
    const content = [];
    for(let i = 0; i < 100; i++) 
        content.push({
            id: `${i}`,
            code: '5321316512335',
            brandCode: `brandCode${i}`,
            brandName: 'brandName',
            dealerCode: `dealerCode${i}`,
            dealerName: 'dealerName',
            createTime: '2019-07-01',
            status: 1,
            claimCode: 'claimCode001',
            claimType: 1,
            invoiceCode: 'invoiceCode001',
            claimAmount: 200,
            totalFee: 5,
            isPrint: true,
            rowVersion: 'string',
            options: [
                'confirm',
                'update',
                'abandon',
                'print'
            ]
        });
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});

router.post('/', (req, res) => {
    res.json({
        message: '新增成功'
    });
});

router.put('/:id', (req, res) => {
    res.json({
        message: '编辑'
    });
});

router.put('/:id/confirm', (req, res) => {
    res.json({
        message: '确认成功'
    });
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

router.put('/:id/print', (req, res) => {
    res.json({
        message: '打印成功'
    });
});

router.get('/forPartClaimCacu', (req, res) => {
    const content = [];
    for(let i = 0; i < 40; i++) content.push({
        id: `${i + 1}`,
        code: 'string',
        brandCode: 'string',
        brandName: 'string',
        dealerCode: 'string',
        claimCode: 'string',
        claimType: 1,
        currency: 1,
        partId: 'string',
        partCode: 'string',
        partName: 'string',
        packingListCode: 'string',
        partSaleOrderCode: 'string',
        claimAmount: 1,
        claimReason: 1,
        price: 1,
        mgmtFee: 1,
        cacuFee: 1,
        cacuQuantity: 1,
    });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 40,
        }
    });
});
router.get('/:id', (req, res) => {
    res.json({
        message: 'ok',
        payload: {
            id: '001',
            partClaimId: '001',
            branchCode: 'branchCode',
            branchName: 'branchName',
            brandId: '1',
            brandCode: 'brandCode',
            brandName: 'brandName',
            dealerId: '1',
            dealerCode: 'dealerCode',
            dealerName: 'dealerName',
            code: 'code',
            status: 1,
            claimCode: 'claimCode',
            createTime: '2019-09-12T07:14:50.087Z',
            invoiceCode: 'invoiceCode',
            invoicedDate: '2019-09-12T07:14:50.087Z',
            claimType: 1,
            receiptDate: '2019-09-12T07:14:50.087Z',
            currency: 1,
            mgmtRate: 0.2,
            isMgmFee: true,
            shipmentDate: '2019-09-12T07:14:50.087Z',
            actualArrivalDate: '2019-09-12T07:14:50.087Z',
            destination: 'destination',
            claimAmount: 100,
            totalFee: 200,
            address: 'address',
            contactNumber: 'contactNumber',
            surveyResults: 'surveyResults',
            preventMeasures: 'preventMeasures',
            treatmentScheme: 1,
            payType: 'payType',
            cacuStatus: 1,
            createName: 'createName',
            operateTime: '2019-09-12T07:14:50.087Z',
            operateName: 'operateName',
            confirmorName: 'confirmorName',
            confirmTime: '2019-09-12T07:14:50.087Z',
            paymentMethod: 1,
            rowVersion: 'rowVersion',
            options: [
                'confirm',
                'update',
                'abandon',
                'print'
            ],
            partClaimReportDetail: [
                {
                    partId: '001',
                    packingListCode: 'packingListCode',
                    partSaleOrderCode: 'partSaleOrderCode',
                    partCode: 'partCode',
                    partName: 'partName',
                    claimAmount: 1,
                    price: 100,
                    claimFee: 120,
                    fobAmount: 110,
                    mgmtFee: 150,
                    totalAmount: 111111,
                    payAmount: 3123111,
                    claimReason: 1,
                    claimResult: 1
                }, {
                    partId: '002',
                    packingListCode: 'packingListCode',
                    partSaleOrderCode: 'partSaleOrderCode',
                    partCode: 'partCode',
                    partName: 'partName',
                    claimAmount: 5,
                    price: 100,
                    claimFee: 120,
                    fobAmount: 110,
                    mgmtFee: 150,
                    totalAmount: 111111,
                    payAmount: 3121111,
                    claimReason: 1,
                    claimResult: 1
                }
            ]

        }
    });
});

module.exports = router;
